import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);
import todolist from "./todolistStore.js"
export default new Vuex.Store({
  state: {
    name: "韩信点兵",
    age: 16
  },
  mutations: {
    changeName(state) {
      state.name = "李雷雷"
    },
    changeAge(state) {
      state.age = 999
    }
  },
  actions: {},
  modules: {
    hehe: {
      // namespaced:true,//开启命名空间,会自动在方法名的额前面加上一个模块名
      state: {
        name: "马佳宁胖如虎"
      },
      mutations: {
        changeName1(state) {
          var t = state
          console.log(t)
          console.log(1)
          state.name = "李雷雷"
          console.log(2)
        },
      }
    },
    xixi: {
      // namespaced:true,//开启命名空间
      state: {
        age: "我部悍将吕三刀"
      },
      mutations: {
        changeAge1(state) {
          state.age = 1000
        }
      }
    },
    //使用模块化之后如果想用state内部的属性需要用语法如下
    // this.$store.state.模块名.属性名
    // todolist属性名属性值为引入了的todolistStore.js模块
    todolist: todolist
  }
});